﻿package com.wandian.view.components.ui
{
	import com.wandian.ApplicationFacade;
	import com.wandian.controller.CLZNoticeName;
	import com.wandian.data.GameData;
	import com.wandian.model.AccountProxy;
	import com.wandian.model.vo.FaceVo;
	import com.wandian.model.vo.PropVo;
	import com.wandian.model.vo.RoomVo;
	import com.wandian.util.CLZButton;
	import com.wandian.util.CLZLlistScrollPanel;
	import com.wandian.util.CLZLoadIcon;
	import com.wandian.util.CLZPanel;
	import com.wandian.util.CLZTabBar;
	import com.wandian.util.CLZZoom;
	import com.wandian.util.GlowFilterManage;
	import com.wandian.util.ToolTip;

	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	import flash.events.TextEvent;
	/**   
	* @author long
	* @QQ 108232706
	* @version 1.0   
	*/   
	public class NationalDayPanel extends CLZPanel
	{
		private var _mcPanel:Sprite;
		private var closeNotice:String;
		private var _global:GameData;
		private var facade:ApplicationFacade;
		private var _arrNum:Array;

		public function NationalDayPanel(param1:Sprite, param2:Array, param3:String="")
		{
			var _loc_8:int=0;
			var _loc_9:ActivityVo=null;
			this._global=GameData.getInstance();
			this.facade=ApplicationFacade.getInstance();
			this._arrNum=[1, 3, 5, 7, 9, 10];
			this.closeNotice=param3;
			this._mcPanel=param1;
			this._mcPanel["sum_txt"].text=param2[0].toString();
			var _loc_4:*=this._arrNum.length;
			var _loc_5:int=0;
			while (_loc_5 < _loc_4)
			{

				if (param2[0] >= this._arrNum[_loc_5])
				{
				}
				if (_loc_5 == (_loc_4 - 1))
				{
					_loc_8=this._arrNum[_loc_5] - param2[0];
					if (_loc_8 < 0)
					{
						_loc_8=0;
					}
					this._mcPanel["count_txt"].text=_loc_8.toString();
					break;
				}
				_loc_5=_loc_5 + 1;
			}
			var _loc_6:*=getChargeXML(param2);
			var _loc_7:int=0;
			while (_loc_7 < _loc_6.length)
			{

				_loc_9=_loc_6[_loc_7] as ActivityVo;
				CLZButton.setButton(this._mcPanel["btn" + _loc_9.id], GameData.tip["DRAW_PRIZE"]);
				this._mcPanel["btn" + _loc_9.id].id=_loc_9.id;
				this._mcPanel["btn" + _loc_9.id].addEventListener(MouseEvent.CLICK, this.onDrawHandler);
				if (_loc_9.state == 0)
				{
					CLZButton.enabled(this._mcPanel["btn" + _loc_9.id], false, 1);
				}
				else if (_loc_9.state == 1)
				{
					CLZButton.enabled(this._mcPanel["btn" + _loc_9.id], true, 1);
				}
				else
				{
					CLZButton.updateMcText(this._mcPanel["btn" + _loc_9.id], GameData.tip["NO_PRIZE"]);
					CLZButton.enabled(this._mcPanel["btn" + _loc_9.id], false, 1);
				}
				_loc_7=_loc_7 + 1;
			}
			super(param1, this.onClose);
			return;
		} 

		private function onDrawHandler(event:MouseEvent):void
		{
			var _loc_2:*=event.target as MovieClip;
			CLZButton.updateMcText(this._mcPanel["btn" + _loc_2.id], GameData.tip["NO_PRIZE"]);
			CLZButton.enabled(this._mcPanel["btn" + _loc_2.id], false, 1);
			this.facade.sendNotification(CLZNoticeName.NATIONAL_DAY_DRAW_REQ, _loc_2.id);
			return;
		} 

		public function onClose():void
		{
			this.facade.sendNotification(this.closeNotice);
			super.remove();
			return;
		} 

		public static function getChargeXML(param1:Array):Array
		{
			var _loc_5:ActivityVo=null;
			var _loc_2:*=GameData.commonXML.invite.item;
			var _loc_3:Array=[];
			var _loc_4:uint=0;
			while (_loc_4 < _loc_2.length())
			{

				_loc_5=new ActivityVo();
				_loc_5.id=_loc_2[_loc_4].@id;
				_loc_5.count=_loc_2[_loc_4].@count;
				_loc_5.gold=_loc_2[_loc_4].@gold;
				_loc_5.stime=_loc_2[_loc_4].@stime;
				_loc_5.etime=_loc_2[_loc_4].@etime;
				_loc_5.state=param1[_loc_5.id];
				_loc_3.push(_loc_5);
				_loc_4=_loc_4 + 1;
			}
			return _loc_3;
		} 

	}
}

class ActivityVo extends Object
{
	public var id:int;
	public var count:int;
	public var gold:int;
	public var stime:uint;
	public var etime:uint;
	public var state:int;

	function ActivityVo()
	{
		return;
	} 

	public function PayBagVo():void
	{
		return;
	} 

}

